(function($){
    $(function(){
    	
    	KindEditor.ready(function(K) {
        	var editor = K.create('#content', {
				items : [
			  		'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
					'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
					'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
					'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
					'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
					'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 
					'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
					'anchor', 'link', 'unlink', '|', 'about'
				],
				uploadJson : window.basePath+'/document/art/upload_'+global.type+'.html',
				allowFileManager : false,
				allowImageUpload:true,
				allowFileUpload:false,
				allowMediaUpload:false,
				allowFlashUpload:false,
				urlType:'domain',
				afterChange:function(){
					this.sync();
				}});
    	});
    	
    	var $subbtn = $("#submit_btn");
        $('#submitForm').validator({
           theme:'yellow_right_effect',
           stopOnError: false,
           timely: 1,
           focusCleanup:true,
           fields: {
               'title': '标题:required;length[1~50];',
               'content': '内容:required;',
               'summary':'摘要:length[1~1000];',
               'expert':'专家名:required;',
               'position':'职称:required;'
           },
           valid: function(){
        	   $subbtn.attr("disabled",true);
        	   $subbtn.val("正在保存，请稍候...");
               $('#submitForm')._ajaxForm(function(r){
                   asyncbox.tips(r.m,r.r==0 ? 'success' : 'error');
                   if(r.r==0) {
                	   fileFunc.isDel = false;
                	   fileFunc.del("save");
                       setTimeout(function(){
                           document.location.reload();
                       }, 2000);
                   }else{
                	   $subbtn.attr("disabled",false);
                	   $subbtn.val("确认保存");
                   }
               });
           }
        });
    });
})(jQuery);